<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Jialeo\LaravelSchemaExtend\Schema;

class AddSortToMissionTemplate extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::table('open_shop_mission_template', function (Blueprint $table) {
            $table->smallInteger('sort')->default(0)->comment('排序，升序')->after('name');
        });

        \App\Models\OpenShop\Site\OpenShopMissionTemplateModel::query()->update(['sort' => \Illuminate\Support\Facades\DB::raw('id')]);
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::table('open_shop_mission_template', function (Blueprint $table) {
            $table->dropColumn('sort');
        });
    }
}
